CFLAGS = -Wall -fpic -coverage -lm
GFLAGS = -o0 -ftest-coverage -fprofile-arcs
MYFLAGS = -Wall -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)
	
unittest1: 
	gcc dominion.c rngs.c unittest1.c -g $(GFLAGS) -o unittest1 $(MYFLAGS)
	
unittest2: 
	gcc dominion.c rngs.c unittest2.c -g $(GFLAGS) -o unittest2 $(MYFLAGS)
	
unittest3:
	gcc dominion.c rngs.c unittest3.c -g $(GFLAGS) -o unittest3 $(MYFLAGS)
	
unittest4:
	gcc dominion.c rngs.c unittest4.c -g $(GFLAGS) -o unittest4 $(MYFLAGS)
	
cardtest1:
	gcc dominion.c rngs.c cardtest1.c -g $(GFLAGS) -o cardtest1 $(MYFLAGS)
	
cardtest2:
	gcc dominion.c rngs.c cardtest2.c -g $(GFLAGS) -o cardtest2 $(MYFLAGS)
	
cardtest3:
	gcc dominion.c rngs.c cardtest3.c -g $(GFLAGS) -o cardtest3 $(MYFLAGS)
	
cardtest4:
	gcc dominion.c rngs.c cardtest4.c -g $(GFLAGS) -o cardtest4 $(MYFLAGS)

advent:
	gcc dominion.c rngs.c randomtestadventurer.c -g $(GFLAGS) -o advent $(MYFLAGS)

council:
	gcc dominion.c rngs.c randomtestcard.c -g $(GFLAGS) -o council $(MYFLAGS)

testdominion: dominion.h dominion_helpers.h
	gcc dominion.c rngs.c testdominion.c -g $(GFLAGS) -o testdominion $(MYFLAGS)

runtest:
	./testdominion > testdominion.out

testdominionout: testdominion runtest
	gcov -b -f dominion.c > testdominioncoverage.out

testshuffle:
	gcc dominion.c rngs.c testutilities.c testshuffle_00.c -g $(GFLAGS) -o testshuffle $(MYFLAGS)

testinit:
	gcc dominion.c rngs.c testutilities.c mytestinit.c -g $(GFLAGS) -o testinit $(MYFLAGS)

testendturn:
	gcc dominion.c rngs.c testutilities.c testendturn.c -g $(GFLAGS) -o testendturn $(MYFLAGS)

testupdatecoins:
	gcc dominion.c rngs.c testutilities.c testupdatecoins.c -g $(GFLAGS) -o testupdatecoins $(MYFLAGS)

testoutpost:
	gcc dominion.c rngs.c testutilities.c testoutpost.c -g $(GFLAGS) -o testoutpost $(MYFLAGS)

testdiscardcard:
	gcc dominion.c rngs.c testutilities.c testdiscardcard.c -g $(GFLAGS) -o testdiscardcard $(MYFLAGS)

testremodel:
	gcc dominion.c rngs.c testutilities.c testremodel.c -g $(GFLAGS) -o testremodel $(MYFLAGS)

integrateEnd:
	gcc dominion.c rngs.c testutilities.c integrateEnd.c -g $(GFLAGS) -o integrateEnd $(MYFLAGS)

testbaron:
	gcc dominion.c rngs.c testutilities.c testbaron.c -g $(GFLAGS) -o testbaron $(MYFLAGS)



unittestresults.out: unittests cardtests cardtests2

unittests:
	gcc dominion.c rngs.c unittest1.c -g $(GFLAGS) -o unittest1 $(CFLAGS)
	./unittest1.exe
	gcov -b dominion.c > unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c unittest2.c -g $(GFLAGS) -o unittest2 $(CFLAGS)
	./unittest2.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c unittest3.c -g $(GFLAGS) -o unittest3 $(CFLAGS)
	./unittest3.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c unittest4.c -g $(GFLAGS) -o unittest4 $(CFLAGS)
	./unittest4.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	
cardtests: clean clean1
	gcc dominion.c rngs.c cardtest1.c -g $(GFLAGS) -o cardtest1 $(CFLAGS)
	./cardtest1.exe
	
cardtests2:
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c cardtest2.c -g $(GFLAGS) -o cardtest2 $(CFLAGS)
	./cardtest2.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c cardtest3.c -g $(GFLAGS) -o cardtest3 $(CFLAGS)
	./cardtest3.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	gcc dominion.c rngs.c cardtest4.c -g $(GFLAGS) -o cardtest4 $(CFLAGS)
	./cardtest4.exe
	gcov -b dominion.c >> unittestresults.out
	rm -f *.gcda *.gcno
	
runadvent:
	./advent > randomtestadventurer.out

runcouncil:
	./council > randomtestcard.out

randomtestadventurer.out: advent runadvent
	gcov -b -f dominion.c > adventurerresults.out

randomtestcard.out: council runcouncil
	gcov -b -f dominion.c > councilresults.out

	
	

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe *.gcov *.gcda *.gcno *.so
	rm -f unittest1.exe unittest1
	rm -f unittest2.exe unittest2
	rm -f unittest3.exe unittest3
	rm -f unittest4.exe unittest4
	rm -f cardtest1.exe cardtest1
	rm -f cardtest2.exe cardtest2
	rm -f cardtest3.exe cardtest3
	rm -f cardtest4.exe cardtest4
	rm -f advent.exe advent
	rm -f council.exe council
	rm -f testdominion.exe testdominion
	rm -f testshuffle.exe testshuffle
	rm -f testinit.exe testinit
	rm -f testendturn.exe testendturn
	rm -f testupdatecoins.exe testupdatecoins
	rm -f testoutpost.exe testoutpost
	rm -f testdiscardcard.exe testdiscardcard
	rm -f testremodel.exe testremodel
	rm -f integrateEnd.exe integrateEnd
	rm -f testbaron.exe testbaron
	